<?php

namespace app\admin\validate;

use think\Validate;

class RoleValidate extends Validate
{
    protected $rule = [
        'name' => 'require|max:30',
        'remark' => 'max:255',
        'status' => 'require|in:0,1',
    ];


    protected $message = [
        'id.require' => '非法请求',
        'id.integer' => '非法请求',
        'role_id.require' => '非法请求',
        'role_id.integer' => '非法请求',
        'menus.require' => '请选择权限',
        'menus.array' => '不合法的权限规则!',
        'name.require' => '请输入角色名称!',
        'name.max' => '角色名称过长',
        'remark.max' => '备注过长!',
        'status.in' => '无效的状态值!',
    ];

    public function sceneAllow()
    {
        return $this->only(['role_id','menus'])
                    ->append('role_id', 'require|integer')
                    ->append('menus','require|array');
    }

    public function sceneSwitch()
    {
        return $this->only(['id','status'])
                    ->append('id', 'require|integer');
                   
    }

    public function sceneEdit()
    {
    	return $this->only(['id','name','remake','status'])
                    ->append('id', 'require|integer');
            
    }   
}